var t = require("../../@babel/runtime/helpers/interopRequireDefault"), e = t(require("../../@babel/runtime/regenerator")), a = require("../../@babel/runtime/helpers/toConsumableArray"), n = require("../../@babel/runtime/helpers/asyncToGenerator"), i = t(require("../../http/directBuyApi")), s = require("../../utils/tool"), r = getApp(), o = (require("../../utils/api.js"), 
require("../../http/userApi.js")), u = new i.default();

Page({
    data: {
        systemInfo: r.data.systemInfo,
        dataList: [],
        status: !1
    },
    onLoad: function(t) {
        this.loadData();
    },
    getStatus: function() {
        var t = this;
        u.noticeStatus(2, 0).then(function(e) {
            t.setData({
                status: e.data.noticeStatus
            }), e.data.noticeStatus || t.overListen();
        }).catch(function(t) {
            wx.hideLoading();
        });
    },
    overListen: function() {
        wx.requestSubscribeMessage({
            tmplIds: [ "MB3dRY6WLJhC1kSxHEjspgF3fHrRuB5UXt2_x9gfVpw" ],
            success: function(t) {
                "accept" == t.MB3dRY6WLJhC1kSxHEjspgF3fHrRuB5UXt2_x9gfVpw ? (wx.showLoading({
                    title: "加载中",
                    mask: !0
                }), u.listen(2).then(function(t) {
                    wx.hideLoading(), (0, s.toastToPage)("订阅成功");
                }).catch(function(t) {
                    wx.hideLoading();
                })) : (0, s.toastToPage)("取消订阅");
            },
            fail: function(t) {
                console.log(t), (0, s.toastToPage)('请去"设置-消息订阅"开启消息通知');
            },
            complete: function(t) {}
        });
    },
    scrollOnBottom: function() {
        this.data.hasMore ? this.loadData() : r.showToast("已加载全部");
    },
    ruleOnTap: function() {
        wx.navigateTo({
            url: "/pages/point-rule/point-rule"
        });
    },
    loadData: function() {
        var t = this;
        return n(e.default.mark(function n() {
            var i, s;
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return 20, i = t.data.dataList.length / 20 + 1, wx.showLoading({
                        title: "加载中…"
                    }), e.prev = 3, e.next = 6, o.pointList(i, 20);

                  case 6:
                    s = e.sent, t.setData({
                        dataList: [].concat(a(t.data.dataList), a(s.data.list)),
                        hasMore: s.data.totalPage > s.data.currPage
                    }), e.next = 13;
                    break;

                  case 10:
                    e.prev = 10, e.t0 = e.catch(3), console.log(e.t0);

                  case 13:
                    return e.prev = 13, wx.hideLoading(), e.finish(13);

                  case 16:
                  case "end":
                    return e.stop();
                }
            }, n, null, [ [ 3, 10, 13, 16 ] ]);
        }))();
    }
});